/**
 * 
 */
package masterlink.futures.vo;

import baytony.util.Assert;
import baytony.util.StringUtil;
import masterlink.futures.util.WebUtils;

/**
 * @author tonyyang
 *
 */
public class SysGroup {

	private final Group group;
	private final GID gid;
	
	public SysGroup(Group group,GID gid) {
		Assert.notNull(group);
		this.group=group;
		this.gid=gid;
	}
	
	public Long getId(){
		return group.getId(); 
	}
	
	public String getName(){
		return WebUtils.ascii2big5(group.getName());
	}
	
	public String getBorker(){
		if(gid!=null){
			return gid.getBroker();
		}
		return "";
	}
	
	public Long getSeq(){
		return group.getSeq();
	}
	
	public String getRemark(){
		return StringUtil.trim(group.getRemark());
	}
	
	public boolean isDealer(){
		return group.isDealer();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("SysGroup [group=");
		builder.append(group);
		builder.append(", gid=");
		builder.append(gid);
		builder.append("]");
		return builder.toString();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gid == null) ? 0 : gid.hashCode());
		result = prime * result + ((group == null) ? 0 : group.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SysGroup other = (SysGroup) obj;
		if (gid == null) {
			if (other.gid != null)
				return false;
		} else if (!gid.equals(other.gid))
			return false;
		if (group == null) {
			if (other.group != null)
				return false;
		} else if (!group.equals(other.group))
			return false;
		return true;
	}
	
}
